//app.js
var MD5 = require("utils/md5.js");

App({

  onLaunch: function (e) {
    let that=this
    console.log(e)
    wx.getSystemInfo({
      success: function(data) {
        that.globalData.systemInfo =data
        delete that.globalData.systemInfo.code
        delete that.globalData.systemInfo.encryptedData
        delete that.globalData.systemInfo.iv
        delete that.globalData.systemInfo.sign
      },
    })
  
  },
 
  globalData: {// 全局变量
    userInfo: {
      uid:"",
      catid:"0",
      behot_time:"0",
      op:"0",
    },// 用户信息
    testUrl: "http://zqkdt.tyfsry.com/", // 测试地址
    formalUrl: "https://kd.youth.cn/",// 正式地址
    name:"12912316",
    systemInfo:{},
    appKey:'E4csPU*Nd5O4soau6Pr&XHmfmN%9t4QJ',
    allInfo:{},
    friendsInfo:{},
    officialHbDetails:{},
    balance:{},
    redmoney:'',
  },

  makeSign: function (obj) { // 全局加密
    if (!obj) { console.log('需要加密的数组对象为空') }
    var str = '';
    //生成key升序数组
    this.makeUrl(obj)
    var arr = Object.keys(obj);
    arr.sort();
    for (var i in arr) {
      str += arr[i] +'='+ obj[arr[i]];
    }
    str += "E4csPU*Nd5O4soau6Pr&XHmfmN%9t4QJ";
    var encrypted = MD5.hexMD5(str);

    return encrypted;
  },
  makeUrl:function(obj){// 拼接参数
    if (!obj) { console.log('需要加密的数组对象为空') }
    var urlStr = '';
    var urlArr = Object.keys(obj);
    for (var i in urlArr) {
      urlStr += urlArr[i] + '=' + obj[urlArr[i]]+'&';
    }
    return urlStr
  },
})


/**
 * 
 * 

platform:devtools
code:061eFRXe0zm7tA1e8kWe0Mg2Ye0eFRXv
encryptedData:HfDSokhSoT8Cqn5rnOb9xwTmnIvRYcZn2kOl07WVWCKYM3c52wuSUveENL RMhPJ//gTvL9Zz2pzfQPO2ncsKMPhiEtuUwIFwdXf2YSg1Lh8LwzQQmM7wf NNWH4a9mzZ05l7h7ETXjHG/J1ABAopDBG9voWt/cRSEKivQZBZUkQG8QYBmA1MkXGS8nqGpFMp8829jXSckMYhrjJ1G cMu0q9ExAvy/wsizd DE6cPbr9ITqtRNO fGB96a0ttJvi4VeKSC1v0Y9ZaKDWgF88bu5rWTfp3Z0htOa24j3RmHDXVJ1nO4AI44eeEh35 9BfPkUH1hgCQSAZ8Va8Py0OuoI0mTs grnGHigdSi5n6r/SFEcBv2fS4vcWz6RcX9X6SJ4MxLvLzg4OiGKu9bIaefos4PdRkuQKhXiZdj/YiY2Tc5Xf15f8kfBiPBg8ORPsrh2zQl4X 4TStQx/tzpESxCzlOnO/4ltF1kOLoO sZrH0Zz w/ZWx9f8 5ICkSVNC1M9VcjWRMD3l6SajFnCQ
iv:ZlcbU47WtII8/p8fV4GlAw
signature:c23b933e6d23d2308d418a3583941f5ce25ed962
sign:6605e7893a64988562ce8f79ad3cbdfb
uid:15752526
channel:6666



uid:15755068
channel:6666
sign:d7605faebe12a4cf1d866749fe3ff876


 */